package org.b3log.view;

import org.b3log.R;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

public class Dialog {
	private static Dialog dialog;

	private Dialog() {
	}

	public static Dialog getInstance() {
		if (null == dialog) {
			dialog = new Dialog();
		}
		return dialog;
	}

	public void exitConfirmDialog(Context context) {
		AlertDialog.Builder builder = new AlertDialog.Builder(context);
		builder.setTitle(R.string.exit_confirm_title);
		builder.setMessage(R.string.exit_confirm_message);
		builder.setPositiveButton(R.string.exit_confirm_exit, new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				dialog.dismiss();
				android.os.Process.killProcess(android.os.Process.myPid());
			}
		});
		builder.setNegativeButton(R.string.exit_confirm_back, new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				dialog.dismiss();
			}
		});
		builder.create().show();
	}
	
	public void checkNetworkDialog(Context context) {
		AlertDialog.Builder builder = new AlertDialog.Builder(context);
		builder.setTitle(R.string.exit_confirm_title);
		builder.setMessage(R.string.check_network);
		builder.setPositiveButton(R.string.positive, new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				dialog.dismiss();
			}
		});
		builder.create().show();
	}
}
